package com.hsy.crm.web.service.impl;

import com.hsy.crm.web.domain.cm.Unified;
import com.hsy.crm.web.domain.po.print.PrintGetPo;
import com.hsy.crm.web.domain.po.print.PrintOrderPo;
import com.hsy.crm.web.domain.vo.print.PrintOrderVo;
import com.hsy.crm.web.mapper.PrintOrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PrintOrderService {

    @Autowired
    PrintOrderMapper printOrderMapper;

    public Unified<PrintOrderPo> getPrintOrder(PrintOrderVo printOrderVo){
        Unified<PrintOrderPo> unified = new Unified<>();

        PrintOrderPo po = new PrintOrderPo();
        po.setOrder(printOrderMapper.getOrder(printOrderVo));
        po.setDetails(printOrderMapper.getOrderDetails(printOrderVo));

        PrintGetPo printGetPo = printOrderMapper.getUserPrint(printOrderVo);
        if( printGetPo == null ){
            printGetPo = printOrderMapper.getSysPrint(printOrderVo);
        }

        po.setPrint(printGetPo);
        unified.setData(po);
        return unified;
    }

}
